import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import axios from 'axios'
// import Vuex from 'vuex'
// import getters from './getters'
// import app from './modules/app'
// import settings from './modules/settings'
// import user from './modules/user'
// import tagsView from './modules/tagsView'
// import permission from './modules/permission'

import {routes, menus} from './routes.js'
import ElementUI from 'element-ui'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n

import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false


var router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next()
})


// Vue.use(ElementUI, { locale })
Vue.use(VueRouter)
Vue.use(ElementUI, {
  locale
})

/**
 * 时间对象的格式化
 */
Date.prototype.format = function(format) {
  /*
   * eg:format="yyyy-MM-dd hh:mm:ss";
   */
  var o = {
    "M+": this.getMonth() + 1,
    "d+": this.getDate(),
    "H+": this.getHours(),
    "m+": this.getMinutes(),
    "s+": this.getSeconds(),
    "q+": Math.floor((this.getMonth() + 3) / 3),
    "S": this.getMilliseconds()
  };

  if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  }

  for (var k in o) {
    if (new RegExp("(" + k + ")").test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    }
  }
  return format;
};


new Vue({
  router,
  // store,
  render: h => h(App)
}).$mount('#app')
